package com.shuai.controller.feign;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.shuai.model.entity.User;
import com.shuai.common.ErrorCode;
import com.shuai.exception.BusinessException;
import com.shuai.mapper.UserMapper;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @ClassName InnerUserServiceImpl
 * @Description TODO
 * @Author OTTO
 * @Date 2023/1/10 19:59
 */
@RestController
@RequestMapping("/feign")
public class InnerUserController {

    @Resource
    private UserMapper userMapper;

    @GetMapping("/getInvokeUser")
    public User getInvokeUser(@RequestParam("accessKey") String accessKey) {
        if(StringUtils.isAnyBlank(accessKey)){
            throw new BusinessException(ErrorCode.PARAMS_ERROR);
        }
        LambdaQueryWrapper<User> lqw = new LambdaQueryWrapper<>();
        lqw.eq(User::getAccessKey,accessKey);
        return userMapper.selectOne(lqw);
    }

    @GetMapping("/get")
    public void get(){
        System.out.println("1111111111111111111111111111111111111111111111");
    }
}
